package com.example.mytayunapi.Service;

import com.example.mytayunapi.Entity.adviceInfo;
import com.example.mytayunapi.Entity.userInfo;
import com.example.mytayunapi.Mapper.adviceInfoMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class adviceInfoServiceImpl implements adviceInfoService{
    @Autowired
    private adviceInfoMapper adviceinfoMapper;

    @Override
    public List<adviceInfo> selectAllAdviceInfo() {
        return adviceinfoMapper.selectAllAdviceInfo();
    }

    @Override
    public List<adviceInfo> selectAllAdviceInfoByAdviceId(Integer Advice_id) {
        return adviceinfoMapper.selectAllAdviceInfoByAdviceId(Advice_id);
    }

    @Override
    public Integer insertAdviceInfo(adviceInfo adviceInfo) {
        return adviceinfoMapper.insertAdviceInfo(adviceInfo);
    }

    @Override
    public Integer deleteAdviceByID(Integer Advice_id) {
        return adviceinfoMapper.deleteAdviceByID(Advice_id);
    }

    //分页
    @Override
    public PageInfo<adviceInfo> getPageInfo(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<adviceInfo> adviceInfo= adviceinfoMapper.selectAllAdviceInfo();
        PageInfo<adviceInfo> pageInfo = new PageInfo<>(adviceInfo);
        return pageInfo;
    }

    @Override
    public Integer insertAdviceContent(adviceInfo adviceinfo) {
        return adviceinfoMapper.insertAdviceContent(adviceinfo);
    }
}
